<template>
  <div>
    <el-container>
      <el-main>
        <el-card>
          <el-input
            id="input-date-field"
            v-model="search"
            size="mini"
            placeholder="输入信息进行搜索"
          />
          <!--后端完成后 最后添加v-loading="loading" -->
          <el-table :key="itemKey" ref="multipleTable" :data="searchHandler()" :fit="true" :show-header="true" v-loading="loading">
            <el-table-column prop="id" label="id" width="50px"></el-table-column>
            <el-table-column prop="companyName" label="部门名称" width="180px"></el-table-column>
            <el-table-column prop="companyPrincipal" label="负责人" width="80px"></el-table-column>
            <el-table-column prop="checker" label="主盘人" width="80px"></el-table-column>
            <el-table-column prop="checkDate" label="盘点日期"></el-table-column>
            <el-table-column prop="keeper" label="材料负责人" width="130px"></el-table-column>
            <el-table-column fixed="right" width="180px">
              <template slot="header" slot-scope="scope">
                <el-button
                  size="mini"
                  type="primary"
                  @click="handleInsert(scope.$index,scope.row)">添 加 盘 点</el-button>
              </template>
              <template slot-scope="scope">
                <el-button
                  mc-type="column-el-button"
                  size="mini"
                  type="primary"
                  @click="handleCheck(scope.$index, scope.row)">盘 点
                </el-button>
                <el-button
                  mc-type="column-el-button"
                  size="mini"
                  type="danger"
                  @click="handleDelete(scope.$index, scope.row)">删 除
                </el-button>
              </template>
            </el-table-column>
          </el-table>
          <div class="block" >
            <el-pagination
              style="margin-left: -5px;"
              :current-page.sync="currentPage"
              :page-size="pageSize"
              layout="total,prev,pager,next"
              :total="pageTotal"
              @size-change="handlePageSizeChange"
              @current-change="handleCurChange"
            ></el-pagination>
          </div>
        </el-card>
      </el-main>
    </el-container>
    <!--添加盘点表表头弹窗-->
    <el-dialog title="添加盘点表" :visible.sync="insFormVisible" :before-close="handleInsClose" width="50%">
      <el-form class="action-form" :model="insForm" label-width="100px">
        <!-- 实时显示搜索内容-->
        <el-form-item label="部门名称">
          <el-select v-model="insForm.companyName" placeholder="请选择部门">
            <el-option
              v-for="depart in allDepartName"
              :key="depart.id"
              :label="depart.departName"
              :value="depart.departName">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="部门负责人">
          <el-input v-model="insForm.companyPrincipal" />
        </el-form-item>
        <el-form-item label="主盘人">
          <el-input v-model="insForm.checker" />
        </el-form-item>
        <el-form-item label="盘点日期">
          <el-date-picker
            v-model="insForm.checkDate"
            type="date"
            placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="材料负责人">
          <el-input v-model="insForm.keeper" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="insFormCancel()">取 消</el-button>
        <el-button type="primary" @click="insFormConfirm()">确 定</el-button>
      </div>
    </el-dialog>
    <!--盘点-->
    <el-dialog title="盘点信息" :visible.sync="checkFormVisible" :fullscreen="true">
      <el-container>
        <el-main width="100%">
          <el-col :xs="24">
            <el-card header="导 出 文 档">
              <el-button type="primary" @click="deriveExcel">导 出 文 档</el-button>
            </el-card>
          </el-col>
          <el-col :xs="24">
            <el-card>
              <!--后端完成后 最后添加v-loading="loading" -->
              <el-table :key="checkTableKey" ref="multipleTable" v-loading="formloading" :data="checkTableData" :fit="true" :show-header="true" >
                <el-table-column label="物资盘点表" align="center">
                  <el-table-column :label="'单位：' + this.checkFormTable.departName" align="center">
                    <el-table-column :label="'单位负责人: ' + this.checkFormTable.departPrincipal" align="center">
                      <el-table-column prop="id" label="id" width="50px"></el-table-column>
                      <el-table-column prop="name" label="物料名称" width="180px" align="center"></el-table-column>
                      <el-table-column prop="specification" label="规格型号" width="100px"></el-table-column>
                    </el-table-column>
                    <el-table-column :label="'材料负责人: ' + this.checkFormTable.formKeeper">
                      <el-table-column prop="unit" label="计量单位" width="100px"></el-table-column>
                      <el-table-column prop="actualNum" label="实有数"></el-table-column>
                    </el-table-column>
                    <el-table-column :label="'主盘人: ' + this.checkFormTable.formChecker">
                      <el-table-column label="账面数" align="center">
                        <el-table-column prop="bookNum" label="数量" width="80px"></el-table-column>
                        <el-table-column prop="price" label="单价" width="80px"></el-table-column>
                        <el-table-column prop="totalPrice" label="金额" width="80px"></el-table-column>
                      </el-table-column>
                    </el-table-column>
                  </el-table-column>
                  <el-table-column label="单位: (盖章)          ">
                    <el-table-column :label="this.checkFormTable.formCheckDate" align="center">
                      <el-table-column label="增多" align="center">
                        <el-table-column prop="increNum" label="数量" width="80px"></el-table-column>
                        <el-table-column prop="increPrice" label="金额" width="80px"></el-table-column>
                      </el-table-column>
                      <el-table-column label="减少" align="center">
                        <el-table-column prop="decreNum" label="数量" width="80px"></el-table-column>
                        <el-table-column prop="decrePrice" label="金额" width="80px"></el-table-column>
                      </el-table-column>
                      <el-table-column prop="remark" label="备注/监盘标记" width="130px"></el-table-column>
                    </el-table-column>
                  </el-table-column>
                </el-table-column>
                <el-table-column fixed="right" width="180px">
                  <template slot="header" slot-scope="scope">
                    <el-button
                      size="mini"
                      type="primary"
                      @click="handleFormInsert(scope.$index,scope.row)">盘 点 物 料</el-button>
                  </template>
                  <template slot-scope="scope">
                    <el-button
                      mc-type="column-el-button"
                      size="mini"
                      type="primary"
                      @click="handleFormUpd(scope.$index, scope.row)">修 改
                    </el-button>
                    <el-button
                      mc-type="column-el-button"
                      size="mini"
                      type="danger"
                      @click="handleFormDelete(scope.$index, scope.row)">删 除
                    </el-button>
                  </template>
                </el-table-column>
              </el-table>
              <div class="block" >
                <el-pagination
                  style="margin-left: -5px;"
                  :current-page.sync="formCurrentPage"
                  :page-size="pageSize"
                  layout="total,prev,pager,next"
                  :total="formPageTotal"
                  @size-change="handleFormPageSize"
                  @current-change="handleFormCurPage"
                ></el-pagination>
              </div>
            </el-card>
          </el-col>
        </el-main>
      </el-container>
    </el-dialog>
    <!--添加盘点表物料信息弹窗-->
    <el-dialog title="盘点物料" :visible.sync="insMaterialVisible" :before-close="handleInsMaterialClose" width="50%">
      <el-form class="action-form" :model="insMaterialForm" label-width="100px">
        <!-- 实时显示搜索内容-->
        <el-form-item label="物资名称">
          <el-autocomplete
            v-model="insMaterialForm.materialName"
            :fetch-suggestions="querySearchAsync"
            placeholder="请输入内容"
            @select="handleSelect"
          ></el-autocomplete>
        </el-form-item>
        <el-form-item label="实有数">
          <el-input v-model="insMaterialForm.actualNum" />
        </el-form-item>
        <el-form-item label="单价">
          <el-input v-model="insMaterialForm.price" />
        </el-form-item>
        <el-form-item label="备注">
          <el-input v-model="insMaterialForm.remark" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="insMaterialCancel()">取 消</el-button>
        <el-button type="primary" @click="insMaterialConfirm()">确 定</el-button>
      </div>
    </el-dialog>
    <!--更新盘点表物料信息弹窗-->
    <el-dialog title="盘点物料" :visible.sync="updMaterialVisible" :before-close="handleUpdMaterialClose" width="50%">
      <el-form class="action-form" :model="updMaterialForm" label-width="100px">
        <!-- 实时显示搜索内容-->
        <el-form-item label="序号">
          <el-input v-model="updMaterialForm.id" :disabled = "true"></el-input>
        </el-form-item>
        <el-form-item label="物资名称">
          <el-input v-model="updMaterialForm.materialName" :disabled = "true"></el-input>
        </el-form-item>
        <el-form-item label="实有数">
          <el-input v-model="updMaterialForm.actualNum" />
        </el-form-item>
        <el-form-item label="单价">
          <el-input v-model="updMaterialForm.price" />
        </el-form-item>
        <el-form-item label="备注">
          <el-input v-model="updMaterialForm.remark" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="updMaterialCancel()">取 消</el-button>
        <el-button type="primary" @click="updMaterialConfirm()">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>

import { getToken } from '@/utils/auth'
import { getAllCheckHeader, insCheckHeader, selAllDepName, selFormById, insFormMaterial, updFormMaterial, delFormMaterial, delHeaderById, deriveExcel } from '@/api/check-report/check-form'
import { selAllBaseInfo } from '@/api/material-purchase/purchase-plan'

export default {
  data() {
    return {
      tableData: [], // 盘点表表头信息
      checkTableData: [], // 盘点表详情信息
      checkFormVisible: false, // 编辑框是否可见
      insFormVisible: false, //  添加盘点表表头弹出框是否可见
      insMaterialVisible: false, // 盘点物料信息框是否可见
      updMaterialVisible: false, // 编辑盘点物料信息框
      loading: true,
      formloading: true,
      search: '',
      pageSize: 10, //  设置每页的数据条数
      pageTotal: 10, //  初始化总条数
      currentPage: 1, //  申请表当前页码
      formCurrentPage: 1, //  盘点表详细表当前页码
      formPageTotal: 10, //  盘点表详情总个数
      pageKey: '', // 分页功能中 table 的key值
      itemKey: '', //  使用key属性强制替换元素，从而触发组件的生命周期钩子或者触发过渡
      checkTableKey: '', // 盘点详情表中的key
      timeout: null, //  设置搜索时的响应时间
      allDepartName: '', // 获取所有部门信息
      materialBaseInfo: [], // 记录物料基本信息
      checkFormTable: {
        departPrincipal: '', // 获取单位负责人
        departName: '', // 在盘点表内获取部门名称
        formKeeper: '', // 获取材料负责人
        formChecker: '', // 主盘人
        formCheckDate: '', // 获取日期
        headId: '' // 记录盘点表表头id
      },
      updForm: {
        id: '',
        materialName: '',
        purchaseNum: '',
        partUsed: '',
        remark: ''
      },
      insForm: {
        companyName: '',
        companyPrincipal: '',
        checker: '',
        checkDate: '',
        keeper: ''
      },
      insMaterialForm: {
        materialName: '',
        actualNum: '',
        price: '',
        remark: ''
      },
      updMaterialForm: {
        id: '',
        materialName: '',
        actualNum: '',
        price: '',
        remark: ''
      },
      headers: {
        Authorization: getToken()
      }
    }
  },
  //  在模板渲染成html或者模板编译进路由前调用 created.即：通常初始化某些属性值，然后再渲染成视图
  created() {
    this.init()
    this.getDepartName()
    // console.log('account: ' + this.account)
  },
  mounted() {
    selAllBaseInfo().then((response) => {
      // console.log('直接输出所有物料信息: ' + response.data)
      this.materialBaseInfo = response.data
    })
  },
  methods: {
    //  初始化界面
    init() {
      getAllCheckHeader(this.currentPage, this.pageSize).then((response) => {
        this.tableData = response.data.checkHeaderLists
        this.pageTotal = response.data.total
        this.loading = false
        this.itemKey = Math.random()
      })
    },
    // 模糊查询
    searchHandler() {
      return this.tableData.filter(data => !this.search ||
        data.checkDate.toLowerCase().includes(this.search.toLowerCase()) ||
        data.companyName.toLowerCase().includes(this.search.toLowerCase()) ||
        data.checker.toLowerCase().includes(this.search.toLowerCase()) ||
        data.companyPrincipal.toLowerCase().includes(this.search.toLowerCase()) ||
        data.keeper.toLowerCase().includes(this.search.toLowerCase()))
    },
    // 获取部门名称
    getDepartName() {
      selAllDepName().then((response) => {
        this.allDepartName = response.data
        // console.log('部门信息：' + this.acoDepartName)
      })
    },
    // 盘点表详情
    handleCheck(index, row) {
      this.checkFormVisible = true
      selFormById(row.id, this.formCurrentPage, this.pageSize).then((response) => {
        this.checkFormTable.departName = row.companyName
        this.checkFormTable.departPrincipal = row.companyPrincipal
        this.checkFormTable.formCheckDate = row.checkDate
        this.checkFormTable.formChecker = row.checker
        this.checkFormTable.formKeeper = row.keeper
        this.checkFormTable.headId = row.id
        this.checkTableData = response.data.checkFormLists
        // 处理每个盘点的物料的金额数据
        for (var i = 0; i < response.data.checkFormLists.length; i++) {
          var simMaterial = response.data.checkFormLists[i]
          simMaterial['totalPrice'] = simMaterial.price * simMaterial.bookNum
          simMaterial['increPrice'] = simMaterial.price * simMaterial.increNum
          simMaterial['decrePrice'] = simMaterial.price * simMaterial.decreNum
          // console.log('数据: ' + simMaterial)
        }
        this.formPageTotal = response.data.total
        this.formloading = false
        this.checkTableKey = Math.random()
        // console.log(this.checkTableKey + ' : ' + this.itemKey)
      })
    },
    // 初始化盘点表表头 每页条数改变时触发 选择一页显示多少行
    handlePageSizeChange(val) {
      console.log(`每页 ${val} 条`)
      this.currentPage = 1
      this.pageSize = val
      this.itemKey = Math.random()
    },
    // 查询盘点表表头 当前页改变时触发 跳转其他页
    handleCurChange(val) {
      console.log(`当前页: ${val}`)
      this.currentPage = val
      getAllCheckHeader(this.currentPage, this.pageSize).then((response) => {
        // console.log('数据: ' + response.data.allMaterials[0].name)
        this.tableData = response.data.checkHeaderLists
        this.pageTotal = response.data.total
        this.itemKey = Math.random()
      }).catch(error => {
        console.log('请求失败')
        console.log(error)
      })
    },
    // 初始化盘点表 每页条数改变时触发 选择一页显示多少行
    handleFormPageSize(val) {
      console.log(`每页 ${val} 条`)
      this.formCurrentPage = 1
      this.pageSize = val
      this.checkTableKey = Math.random()
    },
    // 查询盘点表 当前页改变时触发 跳转其他页
    handleFormCurPage(val) {
      console.log(`当前页: ${val}`)
      this.formCurrentPage = val
      selFormById(this.checkFormTable.headId, this.formCurrentPage, this.pageSize).then((response) => {
        this.checkTableData = response.data.checkFormLists
        // 处理每个盘点的物料的金额数据
        for (var i = 0; i < response.data.checkFormLists.length; i++) {
          var simMaterial = response.data.checkFormLists[i]
          simMaterial['totalPrice'] = simMaterial.price * simMaterial.actualNum
          simMaterial['increPrice'] = simMaterial.price * simMaterial.increNum
          simMaterial['decrePrice'] = simMaterial.price * simMaterial.decreNum
          // console.log('数据: ' + simMaterial)
        }
        this.formPageTotal = response.data.total
        this.formloading = false
        this.checkTableKey = Math.random()
      })
    },
    //  实现实时搜索功能
    //  fetch-suggestions:返回输入建议的方法，仅当你的输入建议数据 resolve 时，通过调用 callback(data:[]) 来返回它
    querySearchAsync(queryString, callback) {
      // console.log('material1:' + this.materialNameDatas)
      var datas = this.materialBaseInfo
      var results = queryString ? datas.filter(this.createStateFilter(queryString)) : datas
      var result = []
      for (var i = 0; i < results.length; i++) {
        result.push({ 'value': results[i].materialName })
        // console.log('material2:' + results[i].materialName)
      }
      // console.log('material3:' + result)
      clearTimeout(this.timeout)
      this.timeout = setTimeout(() => {
        callback(result)
      }, 3000 * Math.random())
    },
    createStateFilter(queryString) {
      return (state) => {
        // console.log('state:' + state.name)
        return (state.materialName.toLowerCase().indexOf(queryString.toLowerCase()) > -1)
      }
    },
    handleSelect(item) {
      console.log(item)
    },
    // 关闭 盘点物料 添加框之前 的操作
    handleInsMaterialClose() {
      this.insMaterialVisible = false
      this.insMaterialForm.materialName = ''
      this.insMaterialForm.actualNum = ''
      this.insMaterialForm.price = ''
      this.insMaterialForm.remark = ''
    },
    // 取消 盘点物料 添加框之前 的操作
    insMaterialCancel() {
      this.insMaterialVisible = false
      this.insMaterialForm.materialName = ''
      this.insMaterialForm.actualNum = ''
      this.insMaterialForm.price = ''
      this.insMaterialForm.remark = ''
    },
    // 打开 盘点物料信息 编辑框
    handleFormUpd(index, row) {
      this.updMaterialVisible = true
      this.updMaterialForm.id = row.id
      this.updMaterialForm.materialName = row.name
      this.updMaterialForm.actualNum = row.actualNum
      this.updMaterialForm.price = row.price
      this.updMaterialForm.remark = row.remark
    },
    //  关闭 添加窗口 之前的操作
    handleInsClose() {
      this.insFormVisible = false
      this.insForm.companyName = ''
      this.insForm.companyPrincipal = ''
      this.insForm.checker = ''
      this.insForm.checkDate = ''
      this.insForm.keeper = ''
    },
    // 关闭 添加物料信息框 之前的操作
    insFormCancel() {
      this.insFormVisible = false
      this.insForm.companyName = ''
      this.insForm.companyPrincipal = ''
      this.insForm.checker = ''
      this.insForm.checkDate = ''
      this.insForm.keeper = ''
    },
    //  添加盘点表表头信息
    handleInsert(index, row) {
      this.insFormVisible = true
    },
    //  打开 盘点表物料信息 弹出框
    handleFormInsert() {
      this.insMaterialVisible = true
    },
    // 关闭 编辑盘点物料信息 弹出框
    handleUpdMaterialClose() {
      this.updMaterialVisible = false
      this.updMaterialForm.id = ''
      this.updMaterialForm.materialName = ''
      this.updMaterialForm.actualNum = ''
      this.updMaterialForm.price = ''
      this.updMaterialForm.remark = ''
    },
    updMaterialCancel() {
      this.updMaterialVisible = false
      this.updMaterialForm.id = ''
      this.updMaterialForm.materialName = ''
      this.updMaterialForm.actualNum = ''
      this.updMaterialForm.price = ''
      this.updMaterialForm.remark = ''
    },
    //  之后可以加一个 判断物料是否在库中存在的条件
    insFormConfirm() {
      if (this.insForm.companyName === '' || this.insForm.companyPrincipal === '' || this.insForm.checkDate === '' || this.insForm.checker === '' || this.insForm.keeper === '') {
        this.$message.error('信息不能为空！')
      } else {
        let date = new Date(this.insForm.checkDate)
        let y = date.getFullYear()
        let m = date.getMonth()+1
        m = m>9?m:'0'+m;
        let d = date.getDate()
        d = d>9?d:'0'+d
        insCheckHeader(this.insForm.companyName, this.insForm.companyPrincipal, this.insForm.checker, y+''+m+''+d, this.insForm.keeper).then(response => {
          this.$message.success(response.message)
          this.insFormVisible = false
          this.loading = true
          this.init()
          this.insForm.companyName = ''
          this.insForm.companyPrincipal = ''
          this.insForm.checker = ''
          this.insForm.checkDate = ''
          this.insForm.keeper = ''
        })
      }
    },
    //  根据 id 删除盘点表
    handleDelete(index, row) {
      this.$confirm('此操作将删除盘点表所有信息, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        delHeaderById(row.id).then((response) => {
          this.$message.success(response.message)
          this.loading = true
          this.init()
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    // 根据 id 删除盘点表中物料信息
    handleFormDelete(index, row) {
      this.$confirm('此操作将删除物料信息, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        delFormMaterial(row.id).then((response) => {
          this.$message.success(response.message)
          this.formloading = true
          selFormById(this.checkFormTable.headId, this.formCurrentPage, this.pageSize).then((res) => {
            // 处理每个盘点的物料的金额数据
            for (var i = 0; i < res.data.checkFormLists.length; i++) {
              var simMaterial = res.data.checkFormLists[i]
              // 计算账面数总金额
              simMaterial['totalPrice'] = simMaterial.price * simMaterial.bookNum
              // 计算增额
              simMaterial['increPrice'] = simMaterial.price * simMaterial.increNum
              // 计算降额
              simMaterial['decrePrice'] = simMaterial.price * simMaterial.decreNum
              // console.log('数据: ' + simMaterial)
            }
            this.checkTableData = res.data.checkFormLists
            this.formPageTotal = res.data.total
            this.formloading = false
            this.checkTableKey = Math.random()
          })
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    // 插入盘点表中物料信息
    insMaterialConfirm() {
      if (this.insMaterialForm.materialName === '') {
        this.$message.error('物料名称信息不能为空！')
      } else if (this.insMaterialForm.actualNum === '') {
        this.$message.error('实有数信息不能为空！')
      } else if (this.insMaterialForm.price === '') {
        this.$message.error('单价信息不能为空！')
      } else {
        this.insMaterialVisible = false
        insFormMaterial(this.checkFormTable.headId, this.insMaterialForm.materialName, this.insMaterialForm.actualNum, this.insMaterialForm.price, this.insMaterialForm.remark).then(
          (response) => {
            this.$message.success(response.message)
            this.formloading = true
            selFormById(this.checkFormTable.headId, this.formCurrentPage, this.pageSize).then((res) => {
              // 处理每个盘点的物料的金额数据
              for (var i = 0; i < res.data.checkFormLists.length; i++) {
                var simMaterial = res.data.checkFormLists[i]
                // 计算账面数总金额
                simMaterial['totalPrice'] = simMaterial.price * simMaterial.bookNum
                // 计算增额
                simMaterial['increPrice'] = simMaterial.price * simMaterial.increNum
                // 计算降额
                simMaterial['decrePrice'] = simMaterial.price * simMaterial.decreNum
                // console.log('数据: ' + simMaterial)
              }
              this.checkTableData = res.data.checkFormLists
              this.formPageTotal = res.data.total
              this.formloading = false
              this.checkTableKey = Math.random()
            })
          }
        )
      }
    },
    //  编辑盘点表详细信息
    updMaterialConfirm() {
      if (this.updMaterialForm.price === '') {
        this.$message.error('单价不能为空！')
      } else {
        this.updMaterialVisible = false
        updFormMaterial(this.updMaterialForm.id, this.updMaterialForm.actualNum, this.updMaterialForm.price, this.updMaterialForm.remark).then((res) => {
          this.$message.success(res.message)
          selFormById(this.checkFormTable.headId, this.formCurrentPage, this.pageSize).then((res) => {
            // console.log('id:' + this.checkFormTable.headId)
            // 处理每个盘点的物料的金额数据
            for (var i = 0; i < res.data.checkFormLists.length; i++) {
              var simMaterial = res.data.checkFormLists[i]
              simMaterial['totalPrice'] = simMaterial.price * simMaterial.bookNum
              simMaterial['increPrice'] = simMaterial.price * simMaterial.increNum
              simMaterial['decrePrice'] = simMaterial.price * simMaterial.decreNum
              // console.log('数据: ' + simMaterial)
            }
            this.checkTableData = res.data.checkFormLists
            this.formPageTotal = res.data.total
            this.formloading = false
            this.checkTableKey = Math.random()
          })
        })
      }
    },
    // 导出文档
    deriveExcel() {
      console.log(this.checkFormTable.headId)
      deriveExcel(this.checkFormTable.headId).then((res) => {
        const link = document.createElement('a')
        const blob = new Blob([res], { type: 'application/vnd.ms-excel' })
        link.style.display = 'none'
        link.href = URL.createObjectURL(blob)
        link.setAttribute('download', this.checkFormTable.departName + '盘点表: ' + this.checkFormTable.formCheckDate + '.xls')
        document.body.appendChild(link)
        link.click()
        document.body.removeChild(link)
      })
    }
  }
}
</script>

<style scoped>
</style>
